/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.hl7.v3.impl;

import java.util.Collection;
import java.util.List;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.hl7.v3.ListTypeType;
import org.hl7.v3.StrucDocCaption;
import org.hl7.v3.StrucDocItem;
import org.hl7.v3.StrucDocList;
import org.hl7.v3.V3Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Struc Doc List</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getCaption <em>Caption</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getItem <em>Item</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getID <em>ID</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getLanguage <em>Language</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getListType <em>List Type</em>}</li>
 *   <li>{@link org.hl7.v3.impl.StrucDocListImpl#getStyleCode <em>Style Code</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StrucDocListImpl extends EObjectImpl implements StrucDocList {
	/**
	 * The cached value of the '{@link #getCaption() <em>Caption</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCaption()
	 * @generated
	 * @ordered
	 */
	protected StrucDocCaption caption;

	/**
	 * The cached value of the '{@link #getItem() <em>Item</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItem()
	 * @generated
	 * @ordered
	 */
	protected EList<StrucDocItem> item;

	/**
	 * The default value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getID() <em>ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getID()
	 * @generated
	 * @ordered
	 */
	protected String iD = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getLanguage() <em>Language</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLanguage()
	 * @generated
	 * @ordered
	 */
	protected static final String LANGUAGE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLanguage() <em>Language</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLanguage()
	 * @generated
	 * @ordered
	 */
	protected String language = LANGUAGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getListType() <em>List Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getListType()
	 * @generated
	 * @ordered
	 */
	protected static final ListTypeType LIST_TYPE_EDEFAULT = ListTypeType.UNORDERED;

	/**
	 * The cached value of the '{@link #getListType() <em>List Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getListType()
	 * @generated
	 * @ordered
	 */
	protected ListTypeType listType = LIST_TYPE_EDEFAULT;

	/**
	 * This is true if the List Type attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean listTypeESet;

	/**
	 * The default value of the '{@link #getStyleCode() <em>Style Code</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStyleCode()
	 * @generated
	 * @ordered
	 */
	protected static final List<String> STYLE_CODE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getStyleCode() <em>Style Code</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStyleCode()
	 * @generated
	 * @ordered
	 */
	protected List<String> styleCode = STYLE_CODE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StrucDocListImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return V3Package.eINSTANCE.getStrucDocList();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StrucDocCaption getCaption() {
		return caption;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCaption(StrucDocCaption newCaption, NotificationChain msgs) {
		StrucDocCaption oldCaption = caption;
		caption = newCaption;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__CAPTION, oldCaption, newCaption);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCaption(StrucDocCaption newCaption) {
		if (newCaption != caption) {
			NotificationChain msgs = null;
			if (caption != null)
				msgs = ((InternalEObject)caption).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - V3Package.STRUC_DOC_LIST__CAPTION, null, msgs);
			if (newCaption != null)
				msgs = ((InternalEObject)newCaption).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - V3Package.STRUC_DOC_LIST__CAPTION, null, msgs);
			msgs = basicSetCaption(newCaption, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__CAPTION, newCaption, newCaption));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StrucDocItem> getItem() {
		if (item == null) {
			item = new EObjectContainmentEList<StrucDocItem>(StrucDocItem.class, this, V3Package.STRUC_DOC_LIST__ITEM);
		}
		return item;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getID() {
		return iD;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setID(String newID) {
		String oldID = iD;
		iD = newID;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__ID, oldID, iD));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLanguage() {
		return language;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLanguage(String newLanguage) {
		String oldLanguage = language;
		language = newLanguage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__LANGUAGE, oldLanguage, language));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ListTypeType getListType() {
		return listType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setListType(ListTypeType newListType) {
		ListTypeType oldListType = listType;
		listType = newListType == null ? LIST_TYPE_EDEFAULT : newListType;
		boolean oldListTypeESet = listTypeESet;
		listTypeESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__LIST_TYPE, oldListType, listType, !oldListTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetListType() {
		ListTypeType oldListType = listType;
		boolean oldListTypeESet = listTypeESet;
		listType = LIST_TYPE_EDEFAULT;
		listTypeESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, V3Package.STRUC_DOC_LIST__LIST_TYPE, oldListType, LIST_TYPE_EDEFAULT, oldListTypeESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetListType() {
		return listTypeESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public List<String> getStyleCode() {
		return styleCode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStyleCode(List<String> newStyleCode) {
		List<String> oldStyleCode = styleCode;
		styleCode = newStyleCode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.STRUC_DOC_LIST__STYLE_CODE, oldStyleCode, styleCode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case V3Package.STRUC_DOC_LIST__CAPTION:
				return basicSetCaption(null, msgs);
			case V3Package.STRUC_DOC_LIST__ITEM:
				return ((InternalEList<?>)getItem()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case V3Package.STRUC_DOC_LIST__CAPTION:
				return getCaption();
			case V3Package.STRUC_DOC_LIST__ITEM:
				return getItem();
			case V3Package.STRUC_DOC_LIST__ID:
				return getID();
			case V3Package.STRUC_DOC_LIST__LANGUAGE:
				return getLanguage();
			case V3Package.STRUC_DOC_LIST__LIST_TYPE:
				return getListType();
			case V3Package.STRUC_DOC_LIST__STYLE_CODE:
				return getStyleCode();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case V3Package.STRUC_DOC_LIST__CAPTION:
				setCaption((StrucDocCaption)newValue);
				return;
			case V3Package.STRUC_DOC_LIST__ITEM:
				getItem().clear();
				getItem().addAll((Collection<? extends StrucDocItem>)newValue);
				return;
			case V3Package.STRUC_DOC_LIST__ID:
				setID((String)newValue);
				return;
			case V3Package.STRUC_DOC_LIST__LANGUAGE:
				setLanguage((String)newValue);
				return;
			case V3Package.STRUC_DOC_LIST__LIST_TYPE:
				setListType((ListTypeType)newValue);
				return;
			case V3Package.STRUC_DOC_LIST__STYLE_CODE:
				setStyleCode((List<String>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case V3Package.STRUC_DOC_LIST__CAPTION:
				setCaption((StrucDocCaption)null);
				return;
			case V3Package.STRUC_DOC_LIST__ITEM:
				getItem().clear();
				return;
			case V3Package.STRUC_DOC_LIST__ID:
				setID(ID_EDEFAULT);
				return;
			case V3Package.STRUC_DOC_LIST__LANGUAGE:
				setLanguage(LANGUAGE_EDEFAULT);
				return;
			case V3Package.STRUC_DOC_LIST__LIST_TYPE:
				unsetListType();
				return;
			case V3Package.STRUC_DOC_LIST__STYLE_CODE:
				setStyleCode(STYLE_CODE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case V3Package.STRUC_DOC_LIST__CAPTION:
				return caption != null;
			case V3Package.STRUC_DOC_LIST__ITEM:
				return item != null && !item.isEmpty();
			case V3Package.STRUC_DOC_LIST__ID:
				return ID_EDEFAULT == null ? iD != null : !ID_EDEFAULT.equals(iD);
			case V3Package.STRUC_DOC_LIST__LANGUAGE:
				return LANGUAGE_EDEFAULT == null ? language != null : !LANGUAGE_EDEFAULT.equals(language);
			case V3Package.STRUC_DOC_LIST__LIST_TYPE:
				return isSetListType();
			case V3Package.STRUC_DOC_LIST__STYLE_CODE:
				return STYLE_CODE_EDEFAULT == null ? styleCode != null : !STYLE_CODE_EDEFAULT.equals(styleCode);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (iD: ");
		result.append(iD);
		result.append(", language: ");
		result.append(language);
		result.append(", listType: ");
		if (listTypeESet) result.append(listType); else result.append("<unset>");
		result.append(", styleCode: ");
		result.append(styleCode);
		result.append(')');
		return result.toString();
	}

} //StrucDocListImpl
